package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the PURCHASE_RETURN database table.
 * 
 */
@Entity
@Table(name="PURCHASE_RETURN")
@NamedQuery(name="PurchaseReturn.findAll", query="SELECT p FROM PurchaseReturn p")
public class PurchaseReturn implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="PURCHASE_RETURN_RETURNID_GENERATOR", sequenceName="SEQ",initialValue=1,allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PURCHASE_RETURN_RETURNID_GENERATOR")
	@Column(name="RETURN_ID")
	private long returnId;

	@Column(name="PURCHASE_ID")
	private BigDecimal purchaseId;

	private BigDecimal refund;

	private BigDecimal refunded;

	@Temporal(TemporalType.DATE)
	@Column(name="RETURN_DATE")
	private Date returnDate;

	@Column(name="RETURN_NUM")
	private String returnNum;

	private String theme;

	//bi-directional many-to-one association to PurchaseReturnDetail
	@OneToMany(mappedBy="purchaseReturn")
	@JSONField(serialize=false)
	private List<PurchaseReturnDetail> purchaseReturnDetails;

	public PurchaseReturn() {
	}

	public long getReturnId() {
		return this.returnId;
	}

	public void setReturnId(long returnId) {
		this.returnId = returnId;
	}

	public BigDecimal getPurchaseId() {
		return this.purchaseId;
	}

	public void setPurchaseId(BigDecimal purchaseId) {
		this.purchaseId = purchaseId;
	}

	public BigDecimal getRefund() {
		return this.refund;
	}

	public void setRefund(BigDecimal refund) {
		this.refund = refund;
	}

	public BigDecimal getRefunded() {
		return this.refunded;
	}

	public void setRefunded(BigDecimal refunded) {
		this.refunded = refunded;
	}

	public Date getReturnDate() {
		return this.returnDate;
	}

	public void setReturnDate(Date returnDate) {
		this.returnDate = returnDate;
	}

	public String getReturnNum() {
		return this.returnNum;
	}

	public void setReturnNum(String returnNum) {
		this.returnNum = returnNum;
	}

	public String getTheme() {
		return this.theme;
	}

	public void setTheme(String theme) {
		this.theme = theme;
	}

	public List<PurchaseReturnDetail> getPurchaseReturnDetails() {
		return this.purchaseReturnDetails;
	}

	public void setPurchaseReturnDetails(List<PurchaseReturnDetail> purchaseReturnDetails) {
		this.purchaseReturnDetails = purchaseReturnDetails;
	}

	public PurchaseReturnDetail addPurchaseReturnDetail(PurchaseReturnDetail purchaseReturnDetail) {
		getPurchaseReturnDetails().add(purchaseReturnDetail);
		purchaseReturnDetail.setPurchaseReturn(this);

		return purchaseReturnDetail;
	}

	public PurchaseReturnDetail removePurchaseReturnDetail(PurchaseReturnDetail purchaseReturnDetail) {
		getPurchaseReturnDetails().remove(purchaseReturnDetail);
		purchaseReturnDetail.setPurchaseReturn(null);

		return purchaseReturnDetail;
	}

}